package com.car.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.car.entity.Integral;
import com.car.entity.User;
import com.car.service.IntegralService;
import com.car.service.UserService;

@Controller
@RequestMapping("/integral")
public class IntegralController {
	
	@Autowired
	IntegralService integralService;
	@Autowired
	UserService userService;
	
	
	@RequestMapping("/Pointdetail")
	public String toPoint(@RequestParam(value="integrationUseType",required=false)Integer integrationUseType,HttpSession session,Model model){
		User user = (User)session.getAttribute("loginSuccess");
		
		List<Integral> list = integralService.selectByUserId(user.getUserId(), integrationUseType);
		model.addAttribute("intelist",list.isEmpty()?null:list);
		User users = userService.selectByPrimaryKey(user.getUserId());
		
		model.addAttribute("user", users);
		model.addAttribute("integrationUseType", integrationUseType);
		
		return "H5phone/integralSubsidiary";
	}

}
